﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.EShop.Common.Utility;
using Runda.EShop.Bll;
using System.Data;

namespace Runda.EShop.Web.Order
{
    public partial class OrderPrint : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<SqlDbParameter> parms = Session["Order_Condition"] as List<SqlDbParameter>;

                DataTable dt = new OrderBll().ExportOrderList(parms);

                //整理dt
                dt.Columns.Add("OrderStatusName");
                foreach (DataRow row in dt.Rows)
                {
                    EnumHelper.OrderStatus status = (EnumHelper.OrderStatus)Convert.ToInt32(row["OrderStatus"].ToString());
                    row["OrderStatusName"] = EnumDescAttribute.GetFieldText(status);
                }

                rptOrderList.DataSource = dt;
                rptOrderList.DataBind();

                if (dt.Rows.Count>0)
                {
                    DataRow dr = dt.Rows[0];

                    lblEntName.Text = dr["EntName"].ToString();
                    lblCustomerName.Text = dr["CustomerName"].ToString();
                    lblOrderCode.Text = dr["OrderCode"].ToString();
                    lblOrderDate.Text = dr["OrderDate"].ToString();
                }
            }
        }
    }
}